home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / zip / portfoli / bootst11.lzh / PF BOOTSTRAP VATIPX PLIBACUDNC < prev    next >
Text File  |  1988-10-10  |  3KB  |  126 lines

  1. /*
  2.  * Copyright (c) 1983 The Regents of the University of California.
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms are permitted
  6.  * provided that the above copyright notice and this paragraph are
  7.  * duplicated in all such forms and that any documentation,
  8.  * advertising materials, and other materials related to such
  9.  * distribution and use acknowledge that the software was developed
  10.  * by the University of California, Berkeley.  The name of the
  11.  * University may not be used to endorse or promote products derived
  12.  * from this software without specific prior written permission.
  13.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  14.  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  15.  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  16.  */
  17.  
  18. #ifndef lint
  19. static char sccsid[] = "@(#)dn11.c    5.2 (Berkeley) 9/13/88";
  20. #endif /* not lint */
  21.  
  22. /*
  23.  * Routines for dialing up on DN-11
  24.  */
  25. #include "tip.h"
  26.  
  27. int dn_abort(), alarmtr();
  28. static jmp_buf jmpbuf;
  29. static int child = -1, dn;
  30.  
  31. dn_dialer(num, acu)
  32.     char *num, *acu;
  33. {
  34.     extern errno;
  35.     char *p, *q, phone[40];
  36.     int lt, nw, connected = 1;
  37.     register int timelim;
  38.  
  39.     if (boolean(value(VERBOSE)))
  40.         printf("\nstarting call...");
  41.     if ((dn = open(acu, 1)) < 0) {
  42.         if (errno == EBUSY)
  43.             printf("line busy...");
  44.         else
  45.             printf("acu open error...");
  46.         return (0);
  47.     }
  48.     if (setjmp(jmpbuf)) {
  49.         kill(child, SIGKILL);
  50.         close(dn);
  51.         return (0);
  52.     }
  53.     signal(SIGALRM, alarmtr);
  54.     timelim = 5 * strlen(num);
  55.     alarm(timelim < 30 ? 30 : timelim);
  56.     if ((child = fork()) == 0) {
  57.         /*
  58.          * ignore this stuff for aborts
  59.          */
  60.         signal(SIGALRM, SIG_IGN);
  61.         signal(SIGINT, SIG_IGN);
  62.         signal(SIGQUIT, SIG_IGN);
  63.         sleep(2);
  64.         nw = write(dn, num, lt = strlen(num));
  65.         exit(nw != lt);
  66.     }
  67.     /*
  68.      * open line - will return on carrier
  69.      */
  70.     if ((FD = open(DV, 2)) < 0) {
  71.         if (errno == EIO)
  72.             printf("lost carrier...");
  73.         else
  74.             printf("dialup line open failed...");
  75.         alarm(0);
  76.         kill(child, SIGKILL);
  77.         close(dn);
  78.         return (0);
  79.     }
  80.     alarm(0);
  81.     ioctl(dn, TIOCHPCL, 0);
  82.     signal(SIGALRM, SIG_DFL);
  83.     while ((nw = wait(<)) != child && nw != -1)
  84.         ;
  85.     fflush(stdout);
  86.     close(dn);
  87.     if (lt != 0) {
  88.         close(FD);
  89.         return (0);
  90.     }
  91.     return (1);
  92. }
  93.  
  94. alarmtr()
  95. {
  96.  
  97.     alarm(0);
  98.     longjmp(jmpbuf, 1);
  99. }
  100.  
  101. /*
  102.  * Insurance, for some reason we don't seem to be
  103.  *  hanging up...
  104.  */
  105. dn_disconnect()
  106. {
  107.  
  108.     sleep(2);
  109.     if (FD > 0)
  110.         ioctl(FD, TIOCCDTR, 0);
  111.     close(FD);
  112. }
  113.  
  114. dn_abort()
  115. {
  116.  
  117.     sleep(2);
  118.     if (child > 0)
  119.         kill(child, SIGKILL);
  120.     if (dn > 0)
  121.         close(dn);
  122.     if (FD > 0)
  123.         ioctl(FD, TIOCCDTR, 0);
  124.     close(FD);
  125. }
  126.